package gk.example.util;

import gk.example.App;

import org.json.JSONObject;

import com.tencent.tauth.IUiListener;
import com.tencent.tauth.Tencent;
import com.tencent.tauth.UiError;

import android.app.Activity;
import android.content.Context;
import android.widget.Toast;
import cn.bmob.v3.BmobUser;
import cn.bmob.v3.listener.OtherLoginListener;

public class LoginUtil {

	/**
	 * 
	 * 描述：微博登陆
	 * 
	 * @return void
	 */
	public static void weiboLogin(final Context context) {
		BmobUser.weiboLogin(context, App.WEIBOKEY, App.WEIBOURL,
				new OtherLoginListener() {

					@Override
					public void onSuccess(JSONObject arg0) {
						// TODO Auto-generated method stub

					}

					@Override
					public void onFailure(int arg0, String arg1) {
						// TODO Auto-generated method stub
						T.show(context, "登录失败,请检查" + arg1, Toast.LENGTH_SHORT);
					}

					@Override
					public void onCancel() {
						// TODO Auto-generated method stub

					}
				});
	}

	private static Tencent mTencent;

	/**
	 * 
	 * 描述： QQ登录
	 * 
	 * @return void
	 */
	public static void qqlogin(Context context) {
		mTencent = Tencent.createInstance(App.QQID, context);
		mTencent = Tencent.createInstance(App.QQID, context);
		if (!mTencent.isSessionValid()) {
			mTencent.login((Activity) context, "QQ", new IUiListener() {

				@Override
				public void onError(UiError arg0) {
					// TODO Auto-generated method stub

				}

				@Override
				public void onComplete(Object arg0) {
					// TODO Auto-generated method stub

				}

				@Override
				public void onCancel() {
					// TODO Auto-generated method stub

				}
			});
		}
	}
}
